<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>最佳拍档</title>
    <meta name="keywords" content="最佳拍档">
    <meta name="description" content="最佳拍档">
    <link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/common/admin/css/style.css}">
    <script th:src="@{/layui/layui.js}" src="/layui/layui.js"></script>
    <script th:src="@{/common/js/jquery-3.3.1.min.js}" src="/common/js/jquery-3.3.1.min.js"></script>
    <style>
        .layui-form-label {
            width: 100px;
        }
        .layui-input-block {
            margin-left: 130px;
        }
    </style>
</head>
<body>
        <!--右侧-->
        <div class="right" style="padding: 20px 20px 0px 20px">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
                <legend id="title">销售详情</legend>
            </fieldset>
            <form class="layui-form" lay-filter="RecordForm" style="padding-bottom: 200px;">
                <div class="layui-form-item" id="openeaId_id">
                    <label class="layui-form-label">平台ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="openeaId" placeholder="暂无" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="userName" placeholder="暂无" required lay-verify="required" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机</label>
                    <div class="layui-input-block">
                        <input type="text" name="phone" placeholder="暂无" required lay-verify="phone" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">学历</label>
                    <div class="layui-input-inline">
                        <select name="education" lay-verify="" disabled>
                            <option value="小学">小学</option>
                            <option value="初中">初中</option>
                            <option value="高中">高中</option>
                            <option value="大专">大专</option>
                            <option value="本科">本科</option>
                            <option value="硕士">硕士</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">年龄</label>
                    <div class="layui-input-block">
                        <input type="text" name="age" placeholder="暂无" lay-verify="number" autocomplete="off" class="layui-input" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">销售岗位</label>
                    <div class="layui-input-block">
                        <select name="post" lay-verify="" disabled>
                            <option value="上游兼职">上游兼职</option>
                            <option value="上游半职">上游半职</option>
                            <option value="上游全职">上游全职</option>
                            <option value="下游兼职">下游兼职</option>
                            <option value="下游半职">下游半职</option>
                            <option value="下游全职">下游全职</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">入职日期</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="entryTime" required lay-verify="required" id="entryTimeid" disabled>
                    </div>
                </div>

            </form>
        </div>
</body>

<script type="text/javascript">
    let OriginalData = {}
    let salesId = ""
    window.onload=function(){
        salesId = GetQueryString("salesId")
        if(isNotNull(salesId)){//编辑
            initFormData(salesId)
        }
        //初始化导航栏选中
        $('a[href="/Admin/Sales/SalesManagement"]').parent().addClass('layui-this');
        $('a[href="/Admin/Sales/SalesManagement"]').parent().parent().parent().addClass('layui-nav-itemed');
    }

    //初始化表单数据
    function initFormData(salesId) {
        $.ajax({
            url: '/sales/'+salesId,
            type: 'get',
            data: {},
            dataType: 'json', // 用于设置响应体的类型 注意 跟 data 参数没关系！！！
            success: function (res) {
                layui.use('form', function(){
                    OriginalData = res.data
                    var form = layui.form;
                    //给表单赋值
                    form.val("RecordForm", {
                        "userName": res.data.userName
                        ,"phone": res.data.phone
                        ,"education": res.data.education
                        ,"age": res.data.age
                        ,"post": res.data.post
                        ,"entryTime": res.data.entryTime
                    });
                });
            }
        });
    }

    //获取地址栏参数
    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]);
        return null;
    }

     /**
     * 判断值是否不为空
     * @param {Object} val
     */
     function isNotNull(val){
        if(val!=='undefined' && val!=="" && val!=null){
            return true
        }
        return false
     }
</script>

</html>
